/*    */ package client;
/*    */ 
/*    */ import server.MapleInventoryManipulator;
/*    */ import tools.MaplePacketCreator;
/*    */ import tools.Randomizer;
/*    */ 
/*    */ public class RockPaperScissors
/*    */ {
/*  9 */   private int round = 0;
/*    */   private boolean ableAnswer = true;
/*    */   private boolean win = false;
/*    */   
/*    */   public RockPaperScissors(MapleClient c, byte mode) {
/* 14 */     c.announce(MaplePacketCreator.getRPSMode((byte)(9 + mode), -1, -1, -1));
/* 15 */     if (mode == 0) {
/* 16 */       c.getPlayer().gainMeso(-1000L, true, true);
/*    */     }
/*    */   }
/*    */   
/*    */   public boolean answer(MapleClient c, int answer) {
/* 21 */     if (this.ableAnswer && !this.win && answer >= 0 && answer <= 2) {
/* 22 */       int response = Randomizer.nextInt(3);
/* 23 */       if (response == answer) {
/* 24 */         c.announce(MaplePacketCreator.getRPSMode((byte)11, -1, (byte)response, (byte)this.round));
/*    */       }
/* 26 */       else if ((answer == 0 && response == 2) || (answer == 1 && response == 0) || (answer == 2 && response == 1)) {
/* 27 */         c.announce(MaplePacketCreator.getRPSMode((byte)11, -1, (byte)response, (byte)(this.round + 1)));
/* 28 */         this.ableAnswer = false;
/* 29 */         this.win = true;
/*    */       } else {
/* 31 */         c.announce(MaplePacketCreator.getRPSMode((byte)11, -1, (byte)response, -1));
/* 32 */         this.ableAnswer = false;
/*    */       } 
/* 34 */       return true;
/*    */     } 
/* 36 */     reward(c);
/* 37 */     return false;
/*    */   }
/*    */   
/*    */   public boolean timeOut(MapleClient c) {
/* 41 */     if (this.ableAnswer && !this.win) {
/* 42 */       this.ableAnswer = false;
/* 43 */       c.announce(MaplePacketCreator.getRPSMode((byte)10, -1, -1, -1));
/* 44 */       return true;
/*    */     } 
/* 46 */     reward(c);
/* 47 */     return false;
/*    */   }
/*    */   
/*    */   public boolean nextRound(MapleClient c) {
/* 51 */     if (this.win) {
/* 52 */       this.round++;
/* 53 */       if (this.round < 10) {
/* 54 */         this.win = false;
/* 55 */         this.ableAnswer = true;
/* 56 */         c.announce(MaplePacketCreator.getRPSMode((byte)12, -1, -1, -1));
/* 57 */         return true;
/*    */       } 
/*    */     } 
/* 60 */     reward(c);
/* 61 */     return false;
/*    */   }
/*    */   
/*    */   public void reward(MapleClient c) {
/* 65 */     if (this.win) {
/* 66 */       MapleInventoryManipulator.addById(c, 4031332 + this.round, (short)1, "", null, 0L, "Obtained from rock, paper, scissors");
/* 67 */     } else if (this.round == 0) {
/* 68 */       c.getPlayer().gainMeso(500L, true, true);
/*    */     } 
/* 70 */     c.getPlayer().setRPS(null);
/*    */   }
/*    */   
/*    */   public void dispose(MapleClient c) {
/* 74 */     reward(c);
/* 75 */     c.announce(MaplePacketCreator.getRPSMode((byte)13, -1, -1, -1));
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\client\RockPaperScissors.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */